package org.dtrd.modules.doctor.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.dtrd.modules.doctor.entity.bean.DoctorTeam;
import org.dtrd.modules.doctor.entity.bean.TeamDoctorInfo;
import org.dtrd.modules.doctor.entity.bean.TeamInfo;
import org.dtrd.modules.doctor.entity.po.DtrdEntRdDoctorTeam;
import org.dtrd.modules.doctor.entity.po.DtrdRlDoctorTeamDoctor;
import org.dtrd.modules.doctor.entity.request.SetTeamDoctorRequest;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 医生团队和医生的关系表 服务类
 * </p>
 *
 * @author QR
 * @since 2021-11-30 16:48:38
 */
public interface IDtrdRlDoctorTeamDoctorService extends IService<DtrdRlDoctorTeamDoctor> {

    /**
     * 设置 医生 和 医生团队 的关系
     *
     * @return 操作结果
     */
    @Transactional(rollbackFor = Exception.class)
    boolean saveDoctorTeamRelation(SetTeamDoctorRequest request);

    boolean saveDoctorTeamRelation(Integer doctorId, Integer newDoctorId);

    /**
     * 删除 医生 和 医生团队 的关系
     */
    @Transactional(rollbackFor = Exception.class)
    boolean removeDoctorTeamRelation(Integer doctorId, Integer teamId);

    /**
     * 查询某个医生的团队下的所有医生的基础信息
     *
     * @param doctorId doctorId
     * @return 医生信息列表
     */
    DoctorTeam getTeamDoctors(Integer doctorId);

    List<TeamDoctorInfo> getTeamDoctorList(Integer doctorId);

    List<TeamDoctorInfo> getTeamDoctorListV2(Integer doctorId);

    /**
     * 获取本人创建或者本人关联的团队下所有医生ID
     *
     * @param doctorId
     * @return
     */
    List<Integer> getTeamDoctorIdList(Integer doctorId);

    /**
     * 获取医生的团队信息
     *
     * @param teamId teamId
     * @return 团队信息
     */
    TeamInfo getTeamInfo(Integer teamId);

    /**
     * 删除医生的团队
     */
    @Transactional(rollbackFor = Exception.class)
    boolean removeDoctorTeam(Integer teamId);

    /**
     * 删除医生关联的团队记录
     *
     * @param doctorIds
     */
    void removeDoctorTeamRelation(List<Integer> doctorIds);

    Integer geTeamIdByDoctorId(Integer doctorId);

    /**
     * 获取本人创建团队或关联团队中第一项
     *
     * @param doctorId
     * @return
     */
    Integer getManageTeamId(Integer doctorId);

    List<Integer> getTeamDoctorIdListByTeamId(Integer teamId);
    List<DtrdEntRdDoctorTeam> getTeamDoctorListByDoctorId(Integer doctorId);
}
